<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>免费体验</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="../src/static/jquery.js"></script>
    <!--<style>-->
        <!--img {-->
            <!--height: 100%;-->
            <!--width: 100%;-->
        <!--}-->
    <!--</style>-->
</head>
<body style="background-color: rgb(208,208,208)">
<div class="container">
    <h3>上海定希自有设备租赁有限公司</h3>
    <div style="margin-top: 5%">
        <div class="form-group">
            <img src="img/433907788514875800.jpg" height="100%" width="100%"/>
        </div>
        <!--<p >输入手机号领取一张体验券，可到下列地址<label class="text-primary">免费</label>体验</p>-->
        <p >输入手机号领取一张体验券，可免费体验</p>
        <div class="row">
            <div class="form-group" >
                <div class="col-xs-3 " style="line-height: 34px;">
                    <label for="phone">手机</label>
                </div>
                <div class="col-xs-7">
                    <input type="text" class="form-control" id="phone" placeholder="请输入手机号码"
                           value="">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-7 col-xs-offset-3">
                <div class="form-group" style="padding-top: 7%">
                    <div class="input-group" style="text-align: center;width: 100%;">
                        <button type="submit" class="btn btn-success  " style="width: 100%" id="btn">免费领取</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--<p class="text-muted">地址：闵行区伊犁南路普华医院</p>
    <p class="form-group text-muted">上海市虹口区天宝路578号 飘鹰世纪大厦</p>
    <div class="row form-group">
        <div class="col-xs-8">
            <img src="img/chacha.jpg" height="100%" width="100%" class="img-circle"/>
        </div>
        <div class="col-xs-4" style="margin-top: 60px">
            <p class="text-danger">更多体验请长按左侧图片进入小程序查找</p>
        </div>
    </div>-->
</div>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script>
//    var phone = $('#phone').value;
    $('#btn').click(function () {
        var phone = document.getElementById('phone').value;

        if (!(/^1[34578]\d{9}$/.test(phone))) {
            alert("手机号码有误，请重填");
            return false;
        }
        console.log(phone);
        $.ajax({
            url:'/api/addCouponInfoOne',
            data:{phone:phone},
            dataType:'json',
            type:'GET',
            success:function (data) {
                alert(data.msg);
                window.location.reload();
            },
            error: function (error) {
                //请求失败  获取的报错信息
                console.log(error);
            }
        })
    });
    window.onload=function(){
    $.ajax({
        url:'/api/weixinExperienceShareConfig',
        dataType:'json',
        type:'GET',
        success:function (ress) {
            wx.config({
                    debug: false,
                    appId: ress.appid,
                    timestamp: ress.timestamp,
                    nonceStr: ress.noncestr,
                    signature: ress.signature,
                    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage']
            });
            wx.ready(function () {
                console.log('分享前')
                wx.onMenuShareTimeline({
                    title: "来查查智能健康检测仪",
                    link: "http://fb.dingxishebei.com/putIn/experienceShare.html",
                    imgUrl: "http://fb.dingxishebei.com/putIn/img/wxlogo2.jpg",
                    success: function (res) {
                        console.log('已分享');
                    },
                    cancel: function (res) {
                        console.log('已取消');
                    },
                    fail: function (res) {
                        console.log(JSON.stringify(res));
                    }
                });

                wx.onMenuShareAppMessage({
                    title: "来查查智能健康检测仪",
                    desc: "快速，全面，一站式智能健康检查设备,在等你！",
                    link: "http://fb.dingxishebei.com/putIn/experienceShare.html",
                    imgUrl: "http://fb.dingxishebei.com/putIn/img/wxlogo2.jpg",
                    success: function (res) {
                        console.log('已分享');
                    },
                    cancel: function (res) {
                        console.log('已取消');
                    },
                    fail: function (res) {
                        console.log(JSON.stringify(res));
                    }
                });
            });
        },

        error: function (error) {
            //请求失败  获取的报错信息
            console.log(error);
        }
    })
}
</script>
</body>
</html>